<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of db_customer
 *
 * @author user
 */
//constanta

class Db_item extends Model{
    //put your code here

    function Db_item(){
        parent::Model();
    }

    //retrieve
    function retr_list_pesanan(){
        $pesanan = $this->db->query("SELECT item.tipe,nama,harga_satuan,pesanan.jumlah,pesanan.deadline,pesanan.keterangan,item.pic_url
                                        FROM item,pesanan
                                        WHERE item.id=pesanan.id");
        $i = 0;
        foreach ($pesanan->result() as $hasil){
            $res[$i] = $hasil;
            $i++;
        }

        return $res;
    }
    
    function retr_list_item(){
        $pesanan = $this->db->query("SELECT kategori,nama,harga_satuan,tipe,jenis,deadline,pic_url
                                        FROM item");
        $i = 0;
        foreach ($pesanan->result() as $hasil){
            $res[$i] = $hasil;
            $i++;
        }

        return $res;
    }
    
    function retr_list_beli(){
        $pesanan = $this->db->query("SELECT item.tipe,nama,harga_satuan,pesanan.jumlah
                                        FROM item,pesanan
                                        WHERE item.id=pesanan.id");
        $i = 0;
        foreach ($pesanan->result() as $hasil){
            $res[$i] = $hasil;
            $i++;
        }

        return $res;
    }
    
    function retr_list_printing(){
        $pesanan = $this->db->query("SELECT item.tipe,nama,harga_satuan,pesanan.jumlah,pesanan.deadline,pesanan.keterangan
                                        FROM item,pesanan
                                        WHERE item.id=pesanan.id");
        $i = 0;
        foreach ($pesanan->result() as $hasil){
            $res[$i] = $hasil;
            $i++;
        }

        return $res;
    }

    //insert
   function insert($jenis, $tipe, $jumlah, $ket, $deadline){
        $data = array(
                'jenis' => $nama,
                'tipe' => $tipe,
                'jumlah' => $jumlah,
                'keterangan' => $ket,
                'deadline' => $deadline,
            );

        $this->db->insert('pesanan', $data);
   }
    //update
    function update($column, $oldval, $newval){
        $this->db->query("UPDATE pesanan SET ". $column. "='$newval' WHERE ". $column. "='$oldval'");
    }
    //delete
    
    function delete_where_id($id){
        $this->db->query("DELETE FROM pesanan WHERE id=$id");
    }

}
?>
